function [y, acc] = forwardeuler2b(n)

% [y, acc] = forwardeuler2b(n)
%
%   Solves y'' = -y using the Forward-Euler Difference method.
%
%   n := # of iterations

acc = zeros(2, n);

a = 0;
b = 10 * pi;
deltax = b / n;

x = 0;
acc(1, 1) = x;
acc(2, 1) = 0;

x = x + deltax;
acc(1, 2) = x;
acc(2, 2) = deltax + deltax^2 / 2;

for k = 3:n
    
    x = x + deltax;
    acc(1, k) = x;
    acc(2, k) = (2*acc(2, k-1) - acc(2, k-2)) / (1 + deltax^2);
    
end

y = acc(2, n);